param (
    [string]$User="",
    [string]$User_pwd="",
    [string]$DatabaseName=""
)

<#
    将Suspended状态的邮箱数据库修改为Healthy,中途会有Initializing状态
#>

$DATA_BACKUP_AGENT_HOME = (Get-ChildItem env:DATA_BACKUP_AGENT_HOME).Value
$Location = $DATA_BACKUP_AGENT_HOME + "\DataBackup\ProtectClient\Plugins\GeneralDBPlugin\bin\applications\exchange\ps1_scripts"
Set-Location -Path $Location
[string]$common_file_path = (Get-Location).Path + "\Common.ps1"
[string]$pssession_name = "ResumePassiveCopyReplication"

# 引用Common.ps1
. $common_file_path

if (!(NewConnection $User $User_Pwd $pssession_name)) {
    return $False
}

$ret = $True
$DB_details = Invoke-Command -Session $Session -ScriptBlock {Get-MailboxDatabaseCopyStatus -Identity $using:DatabaseName}
# 若不存在该数据库
if (!$?) {
    ClosePSSession $pssession_name
    return $False
}
# 恢复邮箱数据库副本
foreach ($db in $DB_details) {
    if ($db.Status -match "Suspended") {
        $db_name = $db.Name
        Invoke-Command -Session $Session -ScriptBlock {Resume-MailboxDatabaseCopy -Identity $using:db_name -Confirm:$False}
        if (!$?) {
            $ret = $False
        }
    }
}
ClosePSSession $pssession_name
return $ret
